package cn.rengy.lang;

import java.time.Duration;
import java.util.concurrent.Callable;
import org.springframework.cache.CacheManager;
public interface CacheService {

    CacheManager getLocalCacheManager();
    CacheManager getRedisCacheManager();

    <T> T getLocalCache(String cacheName, String key, Callable<T> valueLoader) throws Exception;
    <T> T getLocalCacheIncludeNull(String cacheName, String key, Callable<T> valueLoader) throws Exception;

    <T> T getCache(String cacheName,String key,Callable<T> valueLoader) throws Exception;
    <T> T getCacheIncludeNull(String cacheName,String key,Callable<T> valueLoader) throws Exception;
    /**
     * 放入缓存&指定超时时间
     * @param key
     * @param value
     * @param timeout
     */
    <V> void set(String key, V value, Duration timeout);

}
